package com.cs51.seam;
/* PixelNode.java
 * Purpose: provide a representation for a pixel that can be 
 * used both to represent a pixel in an array, or used in a list.
 * This allows for a pixel map to be more flexible and easier to remap, 
 * especially when dealing with different conceptualizations of seams.
 */



public class PixelNode /*implements Comparable*/ {
   
    private int xCoordinate;
    private int yCoordinate;
    
    /* the range of pixels whose values this pixel contains. 
     * for example, a range of 2 will mean that the agregate values are 
     * averaged from pixels up to 2 away. a value of 0 means that this
     * pixel is only representing itself.
     */
    private int range = 0;
    
    /* 'energy' is just the energy from the individual pixel represended 
     * by this node at (x, y). 'agregate energy' contains the energy from
     * surrounding pixels, up to range away, and divided by range.
     */
    private double energy;
    private double agregateEnergy;
    
    
    private double pathCost;
    
    /* used for LL representation. made public because the primary method
     * of interaction with them will be from the outside. 
     */    
    public PixelNode next;
    public PixelNode prev;
    
    public PixelNode(int x, int y, double e) {
        xCoordinate = x;
        yCoordinate = y;
        energy = e;
    }
    
    public void setX(int x) { xCoordinate = x; }

    public void setY(int y) { yCoordinate = y; }

    public int getX() { return xCoordinate; }

    public int getY() { return yCoordinate; }

    public void setEnergy(double e) { energy = e; }

    public double getEnergy() { return energy; }
    
    /* The Comparable interface functions are used for the priority queue.
     * so equals or compare to are in relation to the path cost.
     */
    public int compareTo(PixelNode p) {
        if (energy < p.energy) { return -1;
        } else if (energy > p.energy) { return 1;
        } else return 0;
    }
    
    
    public boolean equals(PixelNode p) {
        return energy == p.energy;
    }
    
}




